package com.ssy.lingxi.purchase.controller.bidding;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.purchase.api.dto.request.BaseAllRequest;
import com.ssy.lingxi.purchase.api.dto.request.BaseDetailsRequest;
import com.ssy.lingxi.purchase.api.dto.request.BaseExamineRequest;
import com.ssy.lingxi.purchase.api.dto.request.bidding.BiddingListRequest;
import com.ssy.lingxi.purchase.api.dto.request.bidding.BiddingProductRequest;
import com.ssy.lingxi.purchase.api.dto.response.bidding.BiddingDetailsResponse;
import com.ssy.lingxi.purchase.api.dto.response.bidding.BiddingListResponse;
import com.ssy.lingxi.purchase.api.dto.response.bidding.BiddingMemberResponse;
import com.ssy.lingxi.purchase.service.bidding.PlatformBiddingService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @menu 平台后台 - 采购竞价单审核
 * @author wrc
 * @version 2.0.0
 * @date 2021/03/23
 */
@RestController
@RequestMapping("/purchase/bidding/platform")
public class PlatformPurchaseBiddingController  extends BaseController {

    @Resource
    PlatformBiddingService platformBiddingService;

    /**
     *采购竞价单查询
     */
    @GetMapping("/list")
    public Wrapper<PageData<BiddingListResponse>> biddingList(BiddingListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.biddingList(request,sysUser);
    }


    /**
     *采购竞价单详情
     */
    @GetMapping("/details")
    public Wrapper<BiddingDetailsResponse> biddingDetails(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.biddingDetails(request,sysUser);
    }

    /**
     *待审核采购竞价单查询
     */
    @GetMapping("/examine/list")
    public Wrapper<PageData<BiddingListResponse>> examineBidding(BiddingListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.examineBidding(request,sysUser);
    }



    /**
     *审核采购竞价单
     */
    @PostMapping("/examine")
    public Wrapper examine(@Validated @RequestBody BaseExamineRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.ecamine(request,sysUser);
    }

    /**
     *批量审核采购竞价单
     */
    @PostMapping("/examine/batch")
    public Wrapper examineBatch(@Validated @RequestBody BaseAllRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.examineBatch(request,sysUser);
    }


    /**
     *需求对接会员列表分页查询
     */
    @GetMapping("/member/page")
    public  Wrapper<PageData<BiddingMemberResponse>>  memberPage(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.memberPage(request,sysUser);
    }




    /**
     *采购物料分页查询
     */
    @GetMapping("/materiel/page")
    public  Wrapper<PageData<BiddingProductRequest>>  materielPage(BaseDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return platformBiddingService.materielPage(request,sysUser);
    }
}
